package org.lex.math.pc;

import java.util.Arrays;
import java.util.Collection;

import org.lex.utils.functor.UnaryFunctor;


public class CombinationTest {
	public static void main(String[] args) {
		int n = 4, r = 2;
		testCombination(n, r);
	}

	static <T> void testPermutation(Collection<T> src, int r) {
		System.out.println("P(" + src.size() + ", " + r + ") = " + PC.permutation(src.size(), r));
		new Permutation<T>(r, src).visit(new PrintFunctor<T>());
	}

	static <T> void testCombination(int n, int r) {
		System.out.println("C(" + n + ", " + r + ") = " + PC.combination(n, r));
		System.out.println(Arrays.deepToString(Combination.combinations(n, r)));
	}

	static class PrintFunctor<T> implements UnaryFunctor<Void, T[]> {
		@Override
		public Void operate(T[] data) {
			for (int i = 0; i < data.length; i++)
				System.out.print(data[i] + " ");
			System.out.println();
			return null;
		}
	}
}
